home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather
- Path: newsfeed.acns.nwu.edu!ftpbox!mothost!schbbs!news
- From: shang@corp.mot.com (David L. Shang)
- Subject: Re: What Should An Exception Handling Do? -- Clarification of rules
- Reply-To: shang@corp.mot.com
- Organization: MOTOROLA
- Date: Tue, 2 Apr 1996 15:47:22 GMT
- Message-ID: <1996Apr2.154722.29777@schbbs.mot.com>
- References: <vwjg2ao6hqp.fsf@osfb.aber.ac.uk>
- Sender: news@schbbs.mot.com (SCHBBS News Account)
- Nntp-Posting-Host: 129.188.128.126
-
- In article <vwjg2ao6hqp.fsf@osfb.aber.ac.uk> pcg@aber.ac.uk (Piercarlo Grandi)
- writes:
- > Therefore exception handling reduces to simply providing a mechanism by
- > which the *author* of a code segment provides a mechanism by which the
- > *user* of that code segment can specify additional cases, as for example
- > in:
- >
- > float sqrt(float n)
- > {
- > if
- > n > 0 -> ...;
- > [] n == 0 -> return 0;
- > [] n < 0 -> return sqrt_negative(n);
- > fi
- > }
- >
- > where the only difficulty is that sqrt_negative must be dynamically
- > scoped instead of statically scoped, for it must be redefinable by the
- > *user* of the procedure.
- >
- > This again means that termination is the only possible outcome for this
- > case too.
- >
-
- Termination? When you execute:
-
- return sqrt_negative(n)
-
- first, you call "sqrt_negative" to get the result, then you do return
- to terminate. It is not the case that you first terminate then you call
- "sqrt_negative". Once your terminate, you can never go back.
-
- If I write code like:
-
- float sqrt(float n)
- {
- if
- n > 0 -> ...;
- [] n == 0 -> return 0;
- [] n < 0 -> { n1= sqrt_negative(n); return n1; }
- fi
- }
-
- Is the program terminated at the point of calling "sqrt_negative"?
- This embedded exception handler exactly provides a resumption
- semantics, which, according to your previous analysis, is the
- only case that exception handling makes any sense(?).
-
-
- David Shang
-